<?php

namespace App\Admin\Actions\Grid\RowActions;


use App\Models\UsersLeaveMsg;
use Closure;
use Dcat\Admin\Grid\RowAction;
use Illuminate\Http\Request;

class ConfirmAction extends RowAction
{
    /**
     * @return string
     */
	protected $title = '   <i class="feather icon-external-link text-custom"></i> <span class="text-custom" title="处理">处理</span> &emsp;';

    public function confirm()
    {
        return '确定已经处理过该条留言内容吗？';
    }

    /**
     * Handle the action request.
     *
     * @param Request $request
     *
     * @return Response
     */
    public function handle(Request $request)
    {
        $model = UsersLeaveMsg::find($this->getKey());
        if ($model->status) {
            return $this->response()->error('当前留言已处理过');
        }
        $model->status = 1;
        $model->save();
        return $this->response()->success('处理成功')->refresh();
    }


    /**
     * @return array
     */
    protected function parameters()
    {
        return [];
    }
}
